package com.kk.execcmd;


/**
 * 一旦某个线程调用了join方法，那么该线程结束后才会运行其他线程。
 */
public class JoinTest {

    public static void main(String[] args) throws InterruptedException {

        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.println("我是线程1");
            }
        });

        Thread thread2 = new Thread(() -> {
            System.out.println("我是线程2");
        });

        Thread thread3 = new Thread(() -> {
            System.out.println("我是线程3");
        });

        Thread thread4 = new Thread(() -> {
            System.out.println("我是线程4");
        });

        Thread thread5 = new Thread(() -> {
            System.out.println("我是线程5");
        });

        Thread thread6 = new Thread(() -> {
            System.out.println("我是线程6");
        });

        thread2.start();
        thread1.start();
        thread1.join();

        thread3.start();
        thread4.start();
        thread5.start();
        thread6.start();
    }
}